package org.rana.example.annotation.controller;

import org.rana.example.annotation.entity.User;
import org.rana.example.annotation.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Class description:
 *
 * @author zhw
 * @version 1.0 16/9/26 上午9:42
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    UserService userService;

    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    public Object selectById(@PathVariable("id") int id) {
        System.out.println("hello");
        System.out.println("hello");

        return userService.selectById(id);
    }

    @RequestMapping(value = "", method = RequestMethod.POST)
    public Object insert(@RequestParam("username") String usernmae,
                         @RequestParam("email") String email) {

        User user = new User();
        user.setUsername(usernmae).setEmail(email);
        System.out.println("hello");

        System.out.println("hello");


        return userService.insert(user);


    }
}
